package com.hyj.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hyj.service.UserRolesService;
import com.hyj.mapper.RoleModulesMapper;
import com.hyj.mapper.RolesMapper;
import com.hyj.mapper.UserRolesMapper;
import com.hyj.entity.UserRoles;

@Service
public class UserRolesServiceImp implements UserRolesService {
	@Autowired
	private UserRolesMapper userRolesmapper;
	@Autowired
	private RolesMapper rolesmapper;
	@Autowired
	private RoleModulesMapper roleModulesmapper;

	@Override
	public List<UserRoles> selectUserRoles(Integer id) {
		// TODO Auto-generated method stub
		return userRolesmapper.selectUserRoles(id);
	}

	@Override
	public List<UserRoles> selectUserRolesByRolesId(Integer id) {
		// TODO Auto-generated method stub
		return userRolesmapper.selectUserRolesByRolesId(id);
	}

	@Override
	public Integer addUserRole(UserRoles userRoles) {
		// TODO Auto-generated method stub
		Integer i = null;
		List<UserRoles> selectUserRolesByRolesId = userRolesmapper
				.selectURByRidAndUid(userRoles);
		if (selectUserRolesByRolesId.size() > 0) {
			i = 10;
		} else {
			i = userRolesmapper.addUserRole(userRoles);
		}
		return i;
	}

	@Override
	public Integer delUserRole(UserRoles userRoles) {
		// TODO Auto-generated method stub
		return userRolesmapper.delUserRole(userRoles);
	}

}
